package com.kimo3412.gradehub.service;


import com.kimo3412.gradehub.entity.Course;
import com.kimo3412.gradehub.repository.CourseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseService {

    @Autowired
    private CourseRepository courseRepository;

    public List<Course> findAllCourses() {
        return courseRepository.findAll();
    }

    public Course findCourseById(Long courseId) {
        return courseRepository.findById(courseId).orElse(null);
    }

    public Course addCourse(Course course) {
        return courseRepository.save(course);
    }
}
